const http = require('http')
const url = require('url')
const server = http.createServer((req,res)=>{
    // console.log(req);
    let urlObj = url.parse(req.url,true)
    // let {pathname,query} = urlObj
    // console.log('pathname='+pathname);
    // console.log(query)
    // console.log(urlObj);
    // console.log(urlObj.pathname)
    // console.log(urlObj.query)
    // console.log(req.headers);
    // console.log(`请求来了，请求的URL是：${req.url}`);
    console.log(urlObj);
    let urlFormat = url.format(urlObj)
    console.log(urlFormat);
})

server.listen(3001,()=>{
    console.log('server is running...')
    console.log(server.address().port);
})